package andev.lopengles2airhockey;

import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ConfigurationInfo;
import android.opengl.GLSurfaceView;
import android.os.Bundle;

import andev.aandroidlib.activity.AActivity;

public class MainActivity extends AActivity {
    private GLSurfaceView mGLSurfaceView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mGLSurfaceView = new GLSurfaceView(this);

        //Check if the system supports opengl es 2
        final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
        final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
        final boolean bSupportES2 = configurationInfo.reqGlEsVersion >= 0x20000;

        if (bSupportES2) {
            //Request an OpenGL ES 2 compatible context
            mGLSurfaceView.setEGLContextClientVersion(2);

            //Set up our renderer
            mGLSurfaceView.setRenderer(new AirHockeyRenderer4(this));
        }
        //mGLSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
        setContentView(mGLSurfaceView);
    }
}
